package org.jwd.storage.dao;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.UpdateProvider;
import org.springframework.stereotype.Repository;

import java.util.HashMap;

/**
 * @author vizz
 * @since 2022/5/19 20:21
 * <p>
 * 回滚操作，任何单条sql都可以进行回滚
 * insert-->update deleted=1;但只有插入成功后才能得到id
 * delete-->update deleted=0;
 * update-->update
 *
 * sql解析且生成逆向是非常复杂的，等你读完SEATA源码后再想想怎么写
 */
@Mapper
@Repository
public interface RollbackMapper {

    @UpdateProvider(type = RollbackSqlProvider.class,method = "rollInsertProvider")
    int rollInsert(HashMap<String, String> map, @Param("tableName") String tableName);

    @UpdateProvider(type = RollbackSqlProvider.class,method = "rollDeleteProvider")
    int rollDelete(HashMap<String, String> map, @Param("tableName") String tableName);

    @UpdateProvider(type = RollbackSqlProvider.class,method = "rollUpdateProvider")
    int rollUpdate(HashMap<String, String> map, @Param("tableName") String tableName);
}

